package com.jiutian.hotel.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.jiutian.db.util.HibernateUtil;
import com.jiutian.hotel.pojo.HotelCommentData;

public class AddCommentAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        String hotelid = request.getParameter("hotelid");
        String commenttype = request.getParameter("commenttype");
        String comment = request.getParameter("comment");
        
        HotelCommentData commentdata = new HotelCommentData();
        commentdata.setHotelid(hotelid);
        commentdata.setCommenttype(commenttype);
        commentdata.setComment(comment);
        PrintWriter pw=response.getWriter();
        if(HibernateUtil.saveObj(commentdata)){
            pw.print("success");
        } else {
            pw.print("err");
        }
        return null;
    }
}
